package com.myproject.myblogserver.utils;

public class TokenUtil {
    /** 从请求头中提取 JWT 令牌 */
    public static String extractToken(String authHeader) {
        if (authHeader == null || !authHeader.startsWith("Bearer ")) {
            throw new IllegalArgumentException("Invalid refresh token");
        }
        return authHeader.substring(7); // 去掉 "Bearer " 前缀
    }

    /** 从 JWT 令牌中提取用户 ID */
    public static Long getUserIdFromToken(String authHeader) {
        return Long.parseLong(JwtUtil.getUserIdFromToken(extractToken(authHeader)));
    }
}